#pragma once
#include "DPrismaticRotoide.h"
#include "../DWorld.h"
#include "../DVector3.h"
#include "DJointGroup.h"

namespace Skill
{
	namespace Ode
	{
		namespace Joints
		{
			void DPrismaticRotoide::CollectManagedMemory()
			{
				_Anchor = nullptr;
				_Axis1 = nullptr;
				_Axis2 = nullptr;
				DJoint::CollectManagedMemory();
			}
			DPrismaticRotoide::DPrismaticRotoide(DWorld^ world , DJointGroup^ group)
				:DJoint(world,group)
			{
				dWorldID w = world? world->_This : NULL;
				dJointGroupID g = group? group->_This : NULL;
				_SetPointer(dJointCreatePR(w,g),true);
			}

			DVector3^ DPrismaticRotoide::Anchor::get()
			{
				if(!_Anchor)
					_Anchor = gcnew DVector3();
				dJointGetPRAnchor(_This,_Anchor->_This);
				return _Anchor;
			}
			void DPrismaticRotoide::Anchor::set(DVector3^ value)
			{
				dJointSetPRAnchor(_This,value->_This[0],value->_This[1],value->_This[2]);
			}

			DVector3^ DPrismaticRotoide::Axis1::get()
			{
				if(!_Axis1)
					_Axis1 = gcnew DVector3();
				dJointGetPRAxis1(_This,_Axis1->_This);
				return _Axis1;
			}
			void DPrismaticRotoide::Axis1::set(DVector3^ value)
			{
				dJointSetPRAxis1(_This,value->_This[0],value->_This[1],value->_This[2]);
			}

			DVector3^ DPrismaticRotoide::Axis2::get()
			{
				if(!_Axis2)
					_Axis2 = gcnew DVector3();
				dJointGetPRAxis2(_This,_Axis2->_This);
				return _Axis2;
			}
			void DPrismaticRotoide::Axis2::set(DVector3^ value)
			{
				dJointSetPRAxis2(_This,value->_This[0],value->_This[1],value->_This[2]);
			}

			void DPrismaticRotoide::SetParam(DJointParameters parameter, dReal value)
			{
				dJointSetPRParam(_This,(int)parameter, value);
			}
			dReal DPrismaticRotoide::GetParam(DJointParameters parameter)
			{
				return dJointGetPRParam(_This,(int)parameter);
			}
			void DPrismaticRotoide::AddTorque(dReal torque)
			{
				dJointAddPRTorque(_This,torque);
			}
			dReal DPrismaticRotoide::Position::get()
			{
				return dJointGetPRPosition(_This);
			}
			dReal DPrismaticRotoide::PositionRate::get()
			{
				return dJointGetPRPositionRate(_This);
			}
		}
	}
}